package com.yb0os1.mapper;

import com.yb0os1.annotation.AutoFill;
import com.yb0os1.entity.Dish;
import com.yb0os1.enumeration.OperationType;
import com.yb0os1.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @AutoFill(value = OperationType.INSERT)
    void insertDish(Dish dish);

    List<DishVO> select(Long categoryId, String name, Integer status);

    void deleteDishAndFlavor(List<Long> ids);

    //根据id查询菜品
    @Select("select * from dish where dish.id = #{id}")
    DishVO selectById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where dish.category_id = #{categoryId}")
    List<Dish> selectByTypeId(Long categoryId);

    @Select("select * from dish where dish.category_id = #{categoryId} and status=#{status}")
    List<Dish> list(Dish dish);


    @Select("select count(*) from dish where status = #{status}")
    Integer selectDishSumByStatus(Integer status);
}
